package com.hyt.it.ogt.kq.service.bm.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hyt.it.ogt.kq.service.bm.model.dto.StudentSubjectDto;
import com.hyt.it.ogt.kq.service.bm.model.entity.*;
import com.hyt.it.ogt.kq.service.bm.model.param.PayOrderListOrderParam;
import com.hyt.it.ogt.kq.service.bm.model.param.PayOrderRefundOrderListParam;
import com.hyt.it.ogt.kq.service.bm.model.vo.*;
import com.hyt.model.PageParam;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;

public interface OrderMapper extends BaseMapper<Order> {

	IPage<PayOrderProject> queryProjectList(PageParam<PayOrderProject> pageParam, @Param("param") OrderParam param,
			@Param("officeId") String officeId);

	IPage<OrderListVo> querylistOrder(PayOrderListOrderParam pageParam);

	public int insertOrderReceiveNofity(Map<String, Object> obj);

	void insertOrderDetails(Map<String, Object> subject);

	void insertOrderSubject(Map<String, Object> subject);

	IPage<OrderInfoVo> orderList(PageParam<OrderInfoVo> pageParam, @Param("payStatus") String payStatus,
			@Param("regId") String regId);

	OrderInfoVo queryOrderInfo(@Param("orderId") String orderId);

	String getStudentValueById(@Param("type") String type, @Param("regId") String regId,
			@Param("projectId") String projectId);

	List<StudentSubjectVo> getStuSubjectListById(@Param("orderId") String orderId);
	
	
	/****
	 * 根据订单id获取支付科目信息
	 * @param orderId
	 * @param status
	 * @return
	 */
	List<StudentSubject> getSubjectListByOrderId(@Param("orderId") String orderId);
	
	
	List<StudentSubject> refundSubjectList(@Param("orderId") String orderId, @Param("refundStatus") List<Integer> refundStatus);
	
	
	
	/**
	 * 查询项目下有正在退款的订单
	 * @param orderId
	 * @param status
	 * @return
	 */
	List<RefundInfo> getRefundSubjectListByProjectId(@Param("projectId") String projectId, @Param("refundStatus") Integer refundStatus);
	
	/**
	 * 查询项目下订单的退款记录
	 * @param orderId
	 * @param status
	 * @return
	 */
	List<RefundInfo> getRefundListByProjectIdAndOrderId(@Param("projectId") String projectId, @Param("orderId") String orderId, @Param("refundStatus") List<Integer> refundStatus);
	
	
	/**
	 * 查询项目下有正在退款的订单
	 * @param orderId
	 * @param status
	 * @return
	 */
	RefundInfo getRefundSubjectListByProjectIdAndSerialNumber(@Param("bmOrderId") String bmOrderId, @Param("serialNumber") String serialNumber, @Param("refundStatus") List<Integer> refundStatus);
	
	List<StudentSubjectDto> queryRefundSubjectsByProjectId(
			@Param("projectId") String projectId, 
			@Param("studentId") String studentId, 
			@Param("subjectId") String subjectId,  
			@Param("payStatus") Integer payStatus,
			@Param("refundStatus") Integer refundStatus);

	int updateSubjectMidOrderRefundStatus(@Param("orderId") String orderId, @Param("ids") List<String> subjectIds, @Param("status") Integer status);
	
	int updateRefundStatus(@Param("orderId") String orderId, @Param("subjectIds") List<String> subjectIds, @Param("status") Integer status);
	
	int updateSubjectMidOrderPayStatus(@Param("orderId") String orderId, @Param("ids") List<String> subjectIds, @Param("status") Integer status);

	int insertRefund(RefundInfo refundInfo);

	void updateRefund(RefundComments refundComments);

	String getSerialNumber(@Param("orderId") String orderId);
	
	String getOrderDetailId(@Param("orderId") String orderId);

	String getBmOrderId(@Param("serialNumber") String serialNumber);

	IPage<OrderListVo> refundOrderList(PayOrderRefundOrderListParam pageParam);

	String getSequence();

	void insertOrder(Order entity);

	IPage<RefundTaskList> refundTaskList(PageParam<RefundTaskList> pageParam, @Param("param") OrderParam param,
			@Param("officeId") String officeId);

	List<OrderInfoVo> querylistOrderVo(@Param("projectId") String projectId, @Param("orderId") String orderId);

	void updateRefundDeleteFlag(@Param("orderId") String orderId);

	Object sumOrderRefund(@Param("orderId") String orderId);

	List<Order> queryList(@Param("projectId") String projectId);

	String getRefundAmountById(@Param("id") String id);

	List<StudentSubject> refundSubjectListDetail(@Param("orderId") String orderId);

	String getUserNameList(@Param("orderId") String orderId);

	String refundSubjectListDetailNameList(@Param("orderId") String orderId);

	IPage<Reconciliation> officeReconciliation(PageParam<Reconciliation> pageParam,
			@Param("officeName") String officeName, @Param("list") List<String> list);

	List<Project> projectList(@Param("officeId") String officeId);

	IPage<ReconciliationList> officeReconciliationList(PageParam<ReconciliationList> pageParam,
			@Param("orderId") String orderId, @Param("projectId") String projectId, @Param("date") String date,
			@Param("orderType") String orderType, @Param("payType") String payType, @Param("officeId") String officeId,
			@Param("dateEnd") String dateEnd);
	
	String getRefundStudentSubjectIdsByRefundOrderId(@Param("refundOrderId") String refundOrderId);
	
	/***
	 * 查询最近的未支付的订单
	 * @param projectId  项目id
	 * @param regId  用户id
	 * @param payStatus  支付状态
	 * @return   最近的未支付的订单
	 */
	Order queryLatestUnPayOrderByProjectIdAndRegId(
			@Param("projectId") String projectId, 
			@Param("regId") String regId, 
			@Param("payStatus") String payStatus);
}
